import { createRouter, createWebHashHistory } from "vue-router";

const routes = [
  {
    path: "/",
    redirect: "/AfterSale",
  },

  /**售后界面 */
  {
    path: "/AfterSale",
    name: "aftersale",
    component: () => import("@/views/AfterSale/index.vue"),
    meta: { title: "售后问答" },
  },
  /**404 */
  {
    path: "/404",
    name: "404",
    component: () => import("@/views/404/index.vue"),
    meta: { title: "404" },
  },
  /** 路由错误 进404 */
  {
    path: "/:pathMatch(.*)*",
    redirect: "/404",
  },
];

const router = createRouter({
  //使用hash路由
  history: createWebHashHistory(),
  routes,
});

router.beforeEach((to, from, next) => {
  document.title = to.meta.title;
  // console.log(to, from);
  next();
});

export default router;
